package com.itheima.chapter07.time;

import java.time.*;

public class JDKdemo6 {
    public static void main(String[] args) {
        //间隔
        LocalDate localDate = LocalDate.of(2021, 03, 19);
        LocalDate localDate2 = LocalDate.of(2024, 11, 25);
        Period between = Period.between(localDate, localDate2);
        System.out.println(between);//P3Y8M6D
        //间隔年份
        int years = between.getYears();
        System.out.println(years);//3
        //间隔总月份
        long totalMonths = between.toTotalMonths();
        System.out.println(totalMonths);//44

        LocalTime localTime = LocalTime.of(12, 13, 14);
        LocalTime localTime1 = LocalTime.of(17, 18, 19);
        Duration duration = Duration.between(localTime, localTime1);
        System.out.println(duration);//PT5H5M5S
        //间隔毫秒
        System.out.println(duration.toMillis());//18305000
        System.out.println(duration.toNanos());//18305000000000

//System.out.println(duration.toSeconds());

    }
}
